package com.nudge.portlet;

import org.apache.commons.lang.StringUtils;

import java.util.Date;

/**
 * Java bean that corresponds to the response of the extraction on transaction data in the Nudge system.
 *
 * @author Frederic Massart
 */
public class NudgeData {

    // TODO change this name
    private Date collectingDate;

    private Long count;

    private Double avgResponseTime;

    private Double maxResponseTime;

    private Double minResponseTime;

    private Double totalTime;

    private Double avgDBResponseTime;
    private Double maxDBResponseTime;
    private Double minDBResponseTime;

    private Integer errors;

    private Long satisfyingClicks;
    private Long tolerableClicks;


    /**
     * Default constructor.
     */
    NudgeData() {
    }

    /**
     * Construtor will map data from Nudge server into the NudgeData bean.
     *
     * @param dataUnparsed the data to parse, contains the information separated by semicolon
     */
    NudgeData(final String dataUnparsed) {
        if (StringUtils.isEmpty(dataUnparsed)) {
            return;
        }


        String[] data = StringUtils.split(dataUnparsed, ";");

        if (data.length != 11) {
            throw new IllegalArgumentException("The data to parse does not respect the format ");
        }


    }


    public Date getCollectingDate() {
        return collectingDate;
    }

    public void setCollectingDate(Date collectingDate) {
        this.collectingDate = collectingDate;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public Double getAvgResponseTime() {
        return avgResponseTime;
    }

    public void setAvgResponseTime(Double avgResponseTime) {
        this.avgResponseTime = avgResponseTime;
    }

    public Double getMaxResponseTime() {
        return maxResponseTime;
    }

    public void setMaxResponseTime(Double maxResponseTime) {
        this.maxResponseTime = maxResponseTime;
    }

    public Double getMinResponseTime() {
        return minResponseTime;
    }

    public void setMinResponseTime(Double minResponseTime) {
        this.minResponseTime = minResponseTime;
    }

    public Double getTotalTime() {
        return totalTime;
    }

    public void setTotalTime(Double totalTime) {
        this.totalTime = totalTime;
    }

    public Double getAvgDBResponseTime() {
        return avgDBResponseTime;
    }

    public void setAvgDBResponseTime(Double avgDBResponseTime) {
        this.avgDBResponseTime = avgDBResponseTime;
    }

    public Double getMaxDBResponseTime() {
        return maxDBResponseTime;
    }

    public void setMaxDBResponseTime(Double maxDBResponseTime) {
        this.maxDBResponseTime = maxDBResponseTime;
    }

    public Double getMinDBResponseTime() {
        return minDBResponseTime;
    }

    public void setMinDBResponseTime(Double minDBResponseTime) {
        this.minDBResponseTime = minDBResponseTime;
    }

    public Integer getErrors() {
        return errors;
    }

    public void setErrors(Integer errors) {
        this.errors = errors;
    }

    public Long getSatisfyingClicks() {
        return satisfyingClicks;
    }

    public void setSatisfyingClicks(Long satisfyingClicks) {
        this.satisfyingClicks = satisfyingClicks;
    }

    public Long getTolerableClicks() {
        return tolerableClicks;
    }

    public void setTolerableClicks(Long tolerableClicks) {
        this.tolerableClicks = tolerableClicks;
    }
}
